home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Applications… / All Shapes with Printing ƒ / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.6 KB  |  145 lines  |  [TEXT/KAHL]

  1. /*
  2.     Misc.c
  3.     
  4.     This file contains utility and menu handling routines.
  5.  
  6.     ©1992  Apple Computer, Inc.
  7.     All rights reserved.
  8. */
  9.  
  10. #include <Desk.h>
  11. #include <Menus.h>
  12.  
  13.  
  14. #include "graphics toolbox.h"
  15. #include "graphics libraries.h"
  16. #include "PrintingManager.h"
  17. #include "graphics shell.h"
  18.  
  19.  
  20. /*------ DoMenuCommand ---------------------------------------------------------------------------------------*/
  21. //
  22. //    This routine handles the dispatching of our menu requests.
  23. //
  24. void DoMenuCommand(long menuResult)
  25. {
  26.     short                menuID;
  27.     short                menuItem;
  28.     Str255                daName;
  29.     OSErr                err;
  30.     gxDialogResult        result;
  31.     
  32.     menuID = menuResult >>16;
  33.     menuItem = menuResult & 0x0000ffff;
  34.     
  35.     switch (menuID)
  36.     {
  37.         case mApple:
  38.             switch (menuItem)
  39.             {
  40.                 case iAbout:        /* display About box */
  41.                     break;
  42.                 
  43.                 default:            /* handle DA selection */
  44.                     GetItem(GetMHandle(mApple), menuItem, daName);
  45.                     OpenDeskAcc(daName);
  46.                     break;
  47.             }
  48.             break;
  49.             
  50.             case mFile:
  51.                 switch (menuItem)
  52.                 {                        
  53.                     case iNew:
  54.                             /* create new window */
  55.                             
  56.                                 err = DoCreateNew();
  57.                         break;
  58.                                                 
  59.                     case iOpen:
  60.                             /* open saved window */
  61.                             
  62.                         break;
  63.                                                 
  64.                     case iClose:
  65.                             /* close front window */
  66.                             
  67.                                 DoDispose(FrontWindow());
  68.                         break;
  69.                                                 
  70.                     case iSave:
  71.                             /* save front window */
  72.                             
  73.                         break;
  74.                                                 
  75.                     case iPageSetup:
  76.                             /* perform page setup */
  77.                             
  78.                                 HiliteMenu(0);
  79.                                 err = DoFormat(FrontWindow(), &result);
  80.                         break;
  81.                                                 
  82.                     case iPrintOne:
  83.                             /* perform print-one */
  84.                             
  85.                             err = DoPrintOneCopy(FrontWindow());
  86.                         break;
  87.                         
  88.                     case iPrint:
  89.                             /* perform print */
  90.                             
  91.                                 HiliteMenu(0);
  92.                                 err = DoPrinting(FrontWindow());
  93.                         break;
  94.  
  95.                     case iQuit:
  96.                         gQuitting = true;
  97.                         break;
  98.                 }
  99.                 break;
  100.                 
  101.             case mEdit:
  102.                 break;
  103.     }
  104.     HiliteMenu(0);
  105. }
  106.  
  107.  
  108.  
  109. /*------ GetDocShape ---------------------------------------------------------------------------------*/
  110. //
  111. //    This utility routine returns the page gxShape (contents) attached to a window's document.
  112. //
  113. gxShape GetDocShape(WindowPtr wind)
  114. {
  115.     TH_Doc    doc;
  116.     gxShape    docPage = nil;
  117.  
  118.     if (wind)
  119.     {
  120.         doc = (TH_Doc) GetWRefCon(wind);
  121.         docPage = (*doc)->docPage;
  122.     }
  123.     
  124.     return docPage;
  125. }
  126.  
  127.  
  128. /*------ GetDocJob -----------------------------------------------------------------------------------*/
  129. //
  130. //    This utility routine returns the print job attached to a window's document.
  131. //
  132. gxJob GetDocJob(WindowPtr wind)
  133. {
  134.     TH_Doc    doc;
  135.     gxJob        docJob = nil;
  136.  
  137.     if (wind)
  138.     {
  139.         doc = (TH_Doc) GetWRefCon(wind);
  140.         docJob = (*doc)->docJob;
  141.     }
  142.     
  143.     return docJob;
  144. }
  145.